import {request} from "@/utils/request";

export const login = (code, nickname, avatarUrl)=>{
    return request({
        url:`/school/wxlogin?data=${code},${nickname},${avatarUrl}`,
        method:'get',
        header:{
            isToken: false,
            repeatSubmit: false
        }
    })
}

export function listArticle(query) {
    return request({
        url: '/article/list',
        method: 'get',
        params: query,
        header:{
            isToken: true,
            repeatSubmit: false
        }
    })
}

export function postArticle(PostArticleDto) {
    return request({
        url: '/article/front/post',
        method: 'post',
        header:{
            isToken: true,
            repeatSubmit: true
        },
        data: PostArticleDto
    })
}

export function getPostById(id) {
    return request({
        url: `/article/front/post/${id}`,
        method: 'get',
        header:{
            isToken: true,
            repeatSubmit: false
        }
    })
}

export function getPostByChannelId(id) {
    return request({
        url: `/article/front/channel/${id}`,
        method: 'get',
        header:{
            isToken: true,
            repeatSubmit: false
        }
    })
}

export function searchPost(data) {
    return request({
        url: '/article/front/search',
        method: 'post',
        header:{
            isToken: true,
            repeatSubmit: true
        },
        data: data
    })
}

export function removePostById(id) {
    return request({
        url: `/article/front/remove/${id}`,
        method: 'delete',
        header:{
            isToken: true,
            repeatSubmit: false
        }
    })
}

